<?php
/**
 * LogModel.class.php       系统日志模型
 *
 * @author                  mashanling(msl-138@163.com)
 * @date                    2012-06-07 10:07:44
 * @last modify             2012-09-06 15:27:24 by mashanling
 */

!defined('ROOT') && exit('Access Denied');

class LogModel extends CommonModel {
    protected $auto = array(//自动填充
        'log_time'     => 'gmtime',
        'admin_ip'     => 'get_client_ip#1',
        'admin_id'     => 'getAdminId',
        'admin_name'   => 'getAdminName',
        'page_url'     => 'getPageUrl',
        'referer_url'  => 'getRefererUrl',
    );
    protected $db_fields = array (
        'log_id'         => null,//自增id
        'content'        => null,//日志内容
        'log_type'       => null,//日志类型
        'log_time'       => null,//日志时间
        'page_url'       => null,//日志页面
        'referer_url'    => null,//来路页面
        'admin_ip'   	 => null,//管理员ip
        'admin_id'   	 => null,//管理员id
        'admin_name'     => null,//管理员姓名
    );
    protected $pk = 'log_id';//主键
    protected $true_table_name = TB_LOG;//表

    /**
     * 获取管理员姓名
     *
     * @author       mashanling(msl-138@163.com)
     * @date         2012-07-09 11:11:54 by mashanling
     * @last modify  2012-07-09 11:11:54 by mashanling
     *
     * @return string 管理 员姓名
     */
    protected function getAdminName() {
        $admin_info = session('__admin__');

        return $admin_info ? $admin_info['realname'] : '';
    }
}